<? // no direct access
defined( '_JEXEC' ) or die( 'Restricted access' ); ?>

<script type="text/javascript" src="<?= JURI::base(true) ?>/media/system/js/jcarousellite.js"></script>
<script type="text/javascript" src="<?= JURI::base(true) ?>/media/system/js/jquery.mousewheel.js"></script>
<script type="text/javascript">
	jQuery(document).ready(
		function(){
			var size = jQuery('.jCarouselLite ul li').size();
				if(size > 8)
					size = 8;
			jQuery('.jCarouselLite').jCarouselLite({
				btnNext: ".next",
				btnPrev: ".prev",
				visible: size,
				mouseWheel: true,
				scroll:8
			});
		}
	);
	
</script>
<link rel="stylesheet" type="text/css" href="<?= JURI::base(true) ?>/modules/mod_pbny_summary/tmpl/styles.css"/> 

<div style="padding:30px 5px 0px; float:left;">
	<input type="button" class="prev button" style="padding:5px;" value="<" />
</div>
<div style="float:left;height:150px;">
	<div class="jCarouselLite">	
		<ul>
			<? 	foreach($weeks as $week_number => $data): ?>	
				<? if(isset($data->game_schedules)):?>
					<? $week_displayed = false; //set week and date not displayed yet ?>					
					<? $dates = array(); //this is for the dates on the bottom ?>
					<? $last_date = '' ?>
					<? foreach($data->game_schedules as $date => $schedules): ?>					
						<?		$cols  = 0;
								foreach($schedules as $schedule): 
									$cols++;
									$first_team_id  = $schedule->first_team_id;
									$second_team_id = $schedule->second_team_id;
									
									$first_team_score  = 0;
									$second_team_score = 0; 
									if(isset($schedule->scores[$first_team_id]))
										$first_team_score  = $schedule->scores[$first_team_id];
									if(isset($schedule->scores[$second_team_id]))
										$second_team_score = $schedule->scores[$second_team_id];
										
									$game_end_status = null;
									if(isset($schedule->game_end_status))
									  $game_end_status = $schedule->game_end_status->code;
						?>						
							<li style="padding-left:10px;">
								<div style="height:30px;">
								<? if (!$week_displayed): ?>
									<h3>WEEK <?= ($week_number + 1) ?></h3>
									<? $week_displayed = true; ?>
								<? endif; ?>						
								</div>
								<table class="schedule" border="0" cellpadding="0" cellspacing="0">
									<? $bg_color = null; 
									   if(isset($schedule->division)):
										 $bg_color = $schedule->division->color;
									?>
										<tr>
											<td colspan="3" style="height:3px">
												<div style="height:100%;background-color:<?= $bg_color ?>"></div>
											</td>
										</tr>
									<? endif; ?>
									<tr>
										<td class="team"><h3><?= $teams[$first_team_id]->abbr ?></h3></td>
										<td valign="bottom"><?= $game_end_status ?></td>
										<td class="team"><h3><?= $teams[$second_team_id]->abbr ?></h3></td>
									</tr>
									<tr style="height:45px;">
										<td class="score" style="border-left:none;">
											<h2><?=  $first_team_score ?></h2>
										</td>
										<td valign="bottom">
											<div class="time">
												<?= strftime('%I:%M %p', strtotime($schedule->schedule)) ?>
											</div>
										</td>
										<td class="score" style="border-right:none;">
											<h2><?= $second_team_score ?></h2>
										</td>
									</tr>
									<tr>
										<td colspan="3" style="font-size:11px;"><?= $venues[$schedule->venue_id]->name ?></td>
									</tr>														
								</table>
								<div style="height:30px;">
								<? if($last_date != $date): ?>
									<h3 style="font-size:.9em; padding-left:.5em;"><?= strftime('%a - %b %d, %Y ', strtotime($date)) ?></h3>
									<? $last_date = $date ?>
								<? endif; ?>
								</div>
							</li>					
						<? 		endforeach;
								$dates[$date] = $cols;
						?>		
					<? endforeach; ?>
				<? endif; ?>
			<? endforeach ?>		
		</ul>
	</div>	
</div>
<div style="padding-top:30px; float:right;">
	<input type="button" class="next button" style="padding:5px;" value=">"/>
</div>

<div class="clear"></div>
